<template>
	<view class="container">
		<view class="cu-form-group">
			<view class="title">姓名</view>
			<input name="input" :value="name" disabled="true"></input>
		</view>
		<view class="cu-form-group">
			<view class="title">电话</view>
			<input name="input" :value="phone" disabled="true"></input>
		</view>
		<!-- #ifndef H5 || APP-PLUS || MP-ALIPAY -->
		<view class="cu-form-group margin-top">
			<view class="title">代理区域</view>
			<picker mode="region" @change="RegionChange" :value="region">
				<view class="picker">
					{{region[0]}}，{{region[1]}}，{{region[2]}}
				</view>
			</picker>
		</view>
		<!-- #endif -->
		
		<view v-if="failMsg.length == 0" class="padding flex flex-direction">
			<button class="cu-btn bg-red margin-tb-sm lg" @click="submit()">提交申请</button>
		</view>
		<view v-if="failMsg.length > 0" class="margin-top response text-df text-red padding">拒绝原因:{{failMsg}}</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				name:'',
				phone:'',
				region: ['河南省', '新乡市', '红旗区'],
				failMsg:''
			}
		},
		onLoad(options){
			this.name = options.name;
			this.phone = options.phone;
		},
		methods: {
			/** 区域选择 **/
			RegionChange(e) {
				this.region = e.detail.value
				console.log(this.region)
			},
			submit(){
				var that = this;
				that.$network.request("AgentAction/addRecord", {
					address : that.region[0] + " " + that.region[1] + " " + that.region[2]
				}, function(res) {
					if(res.data.state){
						uni.showToast({
							icon: 'success',
							title: '申请已提交',
							duration: 1200
						})
					}else{
						that.$api.msg(res.data.msg ? res.data.msg :"申请失败");
						that.failMsg = res.data.bean.failText;
					}
				}, "", function(res) {
					console.error(JSON.stringify(res))
					uni.showToast({
						icon: 'none',
						title: '加载失败',
						duration: 1200
					})
				});
			}
		}
	}
</script>

<style>

</style>
